import { createStore } from 'redux'

//  reducer 是一个纯函数      
function reducerCount (state = 0, action) {
    console.log('action', action)

    switch (action.type) {
        case 'add':
            //  返回新的状态
            return state += action.payload

        case 'sub':

            return state -= action.payload


        default:
            return state
    }



}

//  store 
const store = createStore(reducerCount)


export default store